<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="model.Shop_model"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>JSP Page</title>
		<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" charset="UTF-8">
//			document.ready(function(){
//				$("li").CSS("list-style-type","none")									
//			})

			window.onload=function(){
				
				$("li").css("list-style-type","none");
				
				$("input[type=checkbox]").click(function(){
					if($(this).attr("checked")=="checked"){
						$(this).removeAttr("checked");
					}else{
						$(this).attr("checked","checked");
					}
				})
				
				$("button").click(function(){
					
					$("input[type=checkbox]").each(function(i){
					
						var _this_=this;
						if($(_this_).attr("checked")=="checked"){
							$.ajax({
								type:"get",
								url:"Delete_ser?index="+i,
								async:true,
								success:function(){
									window.location.reload();
								}
								
							});
						}
					})
				});
				
			}
			
		</script>
	</head>

	<body>
		<%
    		if(session.getAttribute("list")==null){
    			out.print("<p>购物车空空如也</p>");
    			
    		}else{
    			
    		
    		List<Object> list = (List<Object>)session.getAttribute("list");
    	       out.print("<ul>");
    	       	float sum  = 0;
    	       	int i = 0;
    	     for(Object  o  :  list){
//  		     out.print("<li >")
    		 
    			String classname = o.getClass().getSimpleName();
    			Shop_model shop = (Shop_model)o;
    			sum+=Float.valueOf(shop.getPrice());
    			out.print("<li id='"+i+"'><input type='checkbox'>商品:"+shop.getName()+"      "+"价格："+shop.getPrice()+"</li>");
    			i++;
    		}
    		out.print("<li>您的总价为:"+sum+"</li>");
    		out.print("</ul>");   		
    	}
    	%>
    	<button>删除商品</button>
	</body>

</html>